<template>
    <view>
       <view class="collect-bgimg">
		   <image  src="http://shuati26.kptedu.com/uploads/image/collectbgimg.png"></image>
		   <text class="head-title">巩固试题，提升应试能力</text>
		   <view class="head-con">
			   <view class="head-con-item">
				   <text>全部收藏（题）</text>
				   <text>{{total}}</text>
			   </view>
			   
			   <view class="head-con-item2">
				   <text>今日收藏（题）</text>
				   <text>{{today_num}}</text>
			   </view>
		   </view>
	   </view>
	   
        
        
        
		<view class="collect-content">
			<view class="main-title">
				<text>收藏练习</text>
			</view>
			<u-empty v-if="list==''"
					mode="list"
					icon="https://shuati26.kptedu.com/uploads/image/data.png"
					text="您还没有收藏记录,快去刷题吧"
					textColor="#666"
					width="300rpx"
					height="300rpx"
			>
			</u-empty>
			<view v-else
			class="wronglist" v-for="(item, index) in list" :key="index" @click="goto_detail(item,'2') ">
				<view style="display: flex;flex-flow: column wrap;">
					<view style="display: flex;flex-flow: row nowrap;align-items: center;">
						<image style="width: 15px;height: 15px;" src="../../../static/img/yellowyuan.png"></image>
						<view style="font-size: 30rpx;margin-left: 20rpx;">{{item.parent_unit}}-{{item.unit_name}}</view>
					</view>
					<text style="color: #9c9c9c;font-size: 25rpx;margin-top: 20rpx;margin-left: 50rpx;">共{{item.num}}题</text>
				</view>
				<image style="width: 15px;height: 15px;" src="../../../static/img/in.png"></image>
			</view>
			
		</view>	
		    
            
       
    </view>
</template>
<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import { mapState } from "vuex";
import noRecode from "@/components/no-recode.vue";
import Error from '@/core/untils/error/index';

export default {
  mixins: [MescrollMixin], // 使用mixin
  data() {
    return {
     mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
     // 下拉刷新的配置(可选, 绝大部分情况无需配置)
     downOption: {
         use: false, // 是否启用下拉刷新; 默认true
         auto: false, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
         native: false // 启用系统自带的下拉组件,默认false;仅mescroll-body生效,mescroll-uni无效(native: true, 则需在pages.json中配置"enablePullDownRefresh":true)
     },
     // 上拉加载的配置(可选, 绝大部分情况无需配置)
     upOption: {
         page: {
             num:0,
             size: 10 // 每页数据的数量,默认10
         },
         noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
         empty: {
             tip: '暂无相关数据'
         }
     },
	  total:'',
	  today_num:'',
	  list:[],
	  
    };
  },
  onLoad(opts) {
   
  },
  onShow() {
	  this.canReset && this.mescroll.resetUpScroll()
	  this.canReset = true
		this.get_collect();
	   
  },
  mounted() {},
  computed: {
   ...mapState(['subject'])
  },
  components: {
  },
  
  methods: {
   async get_collect() {
      let res = await this.$myHttp.post({
           url: this.$myHttp.urlMap.collect,
           data: {
			   province:uni.getStorageSync('choose_cityName')
           },
           needLogin: true
       })
       if (res.code == 1) {
           this.total = res.data.total
		   this.list=res.data.data
		   this.today_num=res.data.today_num
		  
       }
   },
   
   
	
	goto_detail(item, type) {
	              if (item.num == 0) { //如果目录下没有题目，提示用户
	                  this.$myUtils.$prompt.showToast({
	                      icon: 'none',
	                      title: '当前目录下没有题目，请联系老师'
	                  });
	                  return
	              }
	              if (type == '1') {
	                  if (item.is_last == 0) {
	                      //非终极栏目，点击进入下级栏目
	                      this.$openrul('/pagesa/questionBank/detail/index?id=' + item.id + '&from_type=1' + '&name=' + item.name)
	                  } else if (citem.is_last == 1) {
	                      if (this.$myUserLogin.getToken()) {
	                          //终极栏目，点击进入答题页
	                          this.$openrul('/pagesa/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=1' + '&name=' + item.name)
	                      } else {
	                          Error.errorNotLoggedIn();
	                      }
	                  }
	              } else if (type == '2') {
	                  if (this.$myUserLogin.getToken()) {
	                      //历年真题都是终极栏目，点击进入答题页
	                      this.$openrul('/pagesa/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=2' + '&name=' + item.name)
	                  } else {
	                      Error.errorNotLoggedIn();
	                  }
	              }
	          },
   
  }
};
</script>

<style>
    page {
        background: #f7f8fa;
    }
	.collect-bgimg {
	    height: 350rpx;
		
	}
	.collect-bgimg image{
		width: 100%;
		height: 100%;
		z-index: -10;
	}
	.main-title {
	    padding: 30rpx 30rpx;
	        font-size: 41rpx;
	        color: #000;
	        font-weight: 900;
		
	}
	.collect-content{
		margin-top: 50rpx;
	}
	.head-title{
		font-weight: 900;
		    font-size: 41rpx;
		    color: white;
		    margin: 20rpx 10rpx 10rpx 0rpx;
		    position: relative;
		    top: -280rpx;
		    left: 30rpx;
		
	}
	.head-con{
		position: relative;
		    top: -220rpx;
		    display: flex;
		    flex-flow: row nowrap;
		    left: 60rpx;
		    display: flex;
		    justify-content: space-between;
		    width: 520rpx;
	}
	.head-con-item{
		display: flex;
		flex-flow: column wrap;
	}
	.head-con-item2{
		    display: flex;
		    flex-flow: column wrap;
		    border-left: outset;
		    padding-left: 20rpx;
		    height: 140rpx;
		    border-left-color: #f7f8fa;
	}
	.head-con>view>text:nth-child(1){
		font-size: 27rpx;
	}
	.head-con>view>text:nth-child(2){
		font-size: 50rpx;
	}
	
	/**/
	.kaoshi-tiku {
	  
	}
	.kaoshi-tiku-content {
	  width: 92%;
	  margin: 0 auto;
	  display: flex;
	  flex-direction: row;
	  align-items: center;
	  font-size: 16px;
	  padding: 14px 0;
	  border-bottom: solid 1px #f5f5f5;
	  background: #ffffff;
	  border-radius: 10rpx;
	}
	.kaoshi-tiku-content-flex {
	  width: 100%;
	  display: flex;
	  justify-content: space-between;
	  align-items: center;
	}
	.kaoshi-tiku-content>view:nth-child(1){
		padding-left: 20rpx;
	}
	
	.kaoshi-tiku-content .icon-arrow {
	  padding-right: 20rpx;
	  color: #b3b3b3;
	}
	.kaoshi-tiku-content .kaoshi-tiku-content-flex:first-child {
	  padding-bottom: 6px;
	}
	.kaoshi-tiku-content .kaoshi-tiku-content-flex:last-child {
	  font-size: 14px;
	}
	.kaoshi-tiku-content-top {
	  display: flex;
	  align-items: center;
	}
	.kaoshi-tiku-content-top img {
	  width: 20px;
	  height: 22px;
	  margin-right: 10px;
	}
	.kaoshi-tiku-content-bottom {
	  display: flex;
	  align-items: center;
	}
	.kaoshi-tiku-content-flex .icon-dui2 {
	  margin: 2px 2px 0 0;
	  color: #3c7bfc;
	}
	.kaoshi-tiku-bilv {
	  font-size: 22px;
	  color: #000;
	  display: flex;
	  align-items: baseline;
	}
	.kaoshi-remind-title {
	  font-size: 13px;
	  color: #000;
	}
	.kaoshi-head-banner {
	        background: #fff;
	        border-radius: 5px;
	        width: 92%;
	        margin: 10px auto;
	        /* box-shadow: 0 0 10px rgba(208, 208, 208, 0.5); */
	        /* margin-bottom: 18px; */
	        padding: 16px 0 18px 0;
	    }
		.kaoshi-user-top-remind-b {
		    display: flex;
		    justify-content: center;
		    text-align: center;
		    font-size: 14px;
		    color: #c5c5c5;
		}
		
		.kaoshi-user-top-remind-b-view {
		    flex: 1;
		}
		.kaoshi-user-top-remind-b-title {
		    font-size: 18px;
		    color: #000;
		    padding: 4px 0 6px 0;
		}
		
		.kaoshi-remind-title {
		    font-size: 13px;
		    color: #000;
		}
		.kaoshi-user-top-remind-b-title-p{
		  font-size: 15px;
		}
		/* #ifdef MP-WEIXIN */
		.kaoshi-xcx {
		    background: #fddddd;
		    padding: 8px 0;
		}
		/* #endif */
		.kaoshi-user-top-remind-b-title-content {
		    display: flex;
		    align-items: baseline;
		    justify-content: center;
		}
	.wronglist{
		display: flex;
		    flex-flow: row nowrap;
		    justify-content: space-between;
		    width: 88%;
		    background-color: #ffffff;
		    align-items: center;
		    margin: auto;
		    border-radius: 5px;
		    padding: 0 20rpx;
		    height: 75px;
		    margin-top: 20rpx;
	}
   
</style>
